home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / callin1g / frmdispl.frm (.txt) < prev    next >
Visual Basic Form  |  1999-08-17  |  18KB  |  412 lines

  1. VERSION 5.00
  2. Begin VB.Form frmDisplay 
  3.    AutoRedraw      =   -1  'True
  4.    BackColor       =   &H00000000&
  5.    BorderStyle     =   3  'Fixed Dialog
  6.    ClientHeight    =   8595
  7.    ClientLeft      =   150
  8.    ClientTop       =   1050
  9.    ClientWidth     =   10365
  10.    ControlBox      =   0   'False
  11.    Icon            =   "frmDisplay.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    MouseIcon       =   "frmDisplay.frx":08CA
  16.    MousePointer    =   99  'Custom
  17.    ScaleHeight     =   8595
  18.    ScaleWidth      =   10365
  19.    ShowInTaskbar   =   0   'False
  20.    WindowState     =   2  'Maximized
  21.    Begin VB.PictureBox picBack 
  22.       AutoRedraw      =   -1  'True
  23.       AutoSize        =   -1  'True
  24.       BackColor       =   &H00000000&
  25.       Height          =   23595
  26.       Left            =   -26400
  27.       ScaleHeight     =   23535
  28.       ScaleWidth      =   27420
  29.       TabIndex        =   2
  30.       Top             =   -22680
  31.       Visible         =   0   'False
  32.       Width           =   27480
  33.    End
  34.    Begin VB.PictureBox picBuf 
  35.       AutoRedraw      =   -1  'True
  36.       AutoSize        =   -1  'True
  37.       BackColor       =   &H00000000&
  38.       BorderStyle     =   0  'None
  39.       Height          =   6735
  40.       Left            =   -7440
  41.       ScaleHeight     =   6735
  42.       ScaleWidth      =   8850
  43.       TabIndex        =   1
  44.       Top             =   -5520
  45.       Width           =   8850
  46.    End
  47.    Begin VB.Timer tmrMove 
  48.       Enabled         =   0   'False
  49.       Interval        =   50
  50.       Left            =   1680
  51.       Top             =   7440
  52.    End
  53.    Begin VB.PictureBox picSpr 
  54.       AutoRedraw      =   -1  'True
  55.       AutoSize        =   -1  'True
  56.       Height          =   6195
  57.       Left            =   -4440
  58.       Picture         =   "frmDisplay.frx":0A1C
  59.       ScaleHeight     =   6135
  60.       ScaleWidth      =   6135
  61.       TabIndex        =   0
  62.       Top             =   -4680
  63.       Visible         =   0   'False
  64.       Width           =   6195
  65.    End
  66. Attribute VB_Name = "frmDisplay"
  67. Attribute VB_GlobalNameSpace = False
  68. Attribute VB_Creatable = False
  69. Attribute VB_PredeclaredId = True
  70. Attribute VB_Exposed = False
  71. Option Explicit
  72. '========================================================='
  73. '========================================================='
  74. '=============== RPG Game Version 0.0.2 =================='
  75. '============== Written by Matthew Eagar ================='
  76. '============ Compiled in Visual Basic 6.0 ==============='
  77. '========================================================='
  78. '========================================================='
  79. '   This program is an example of an RPG game engine made
  80. '   with VB 6.0.  I drew all the graphics in MS Paint,
  81. '   and all coding is origional.
  82. '   This isn't ment to be a full game, just a working engine.
  83. '   there is no actual objective.  I havn't yet got doors
  84. '   working, because that would require me to draw some more
  85. '   textures for the insides of houses, which takes FOREVER!
  86. '   Also, the textures could REALLY use some work,
  87. '   as they were drawn in MS Paint.
  88. '   This program may not run well on some computers.
  89. '   The method used, bitblt, works well, but isn't designed for games.
  90. '   It runs fine on a Pentium 233, but slow on a P75.  I havn't tested
  91. '   it on anything in between those.
  92. '   I'm still working on this, so look for me to post newer versions
  93. '   of it.  It'll remain free, and it's really ment for educational purposes.
  94. '   Please contact me with ANY questions, comments, suggestions, or problems,
  95. '   ANY input is welcome:
  96. '   email:  meagar@home.com
  97. '   ICQ:    45058462
  98. '   Also, I havn't tested this on any computer running anything less then VB6.
  99. '   I did run it in vb5, but it took some work.
  100. '   You will need the VB6 runtime files the use this.
  101. '   Updates to Version 2:
  102. '   Added side scrolling and top scrolling
  103. '   Rechanged the map size from 13x11 to 30x30 tiles to accomidate side scrolling
  104. '   Added Bridge Tiles for bridge construction
  105. '   Added sound effects
  106. '   re-wrote most of movement code
  107. Dim animX As Integer    'holds the current x location of the animation frame
  108. Dim animY As Integer    'holds the current y location of the animation frame
  109. Dim direction As Integer    'the direction the characters facing
  110. Dim charX As Integer       'holds the character's x coords
  111. Dim charY As Integer       'holds the character's y coords
  112. Dim lastX As Integer    'holds the character's last y coords
  113. Dim lastY As Integer    'holds the character's last x coords
  114. Dim BackBuilt As Integer 'determines if the back ground needs to be built
  115. Dim Speed As Integer    'holds the current speed, set by pressing the + or - keys
  116. Dim mapx As Integer     'holds the current map x number
  117. Dim mapy As Integer     'holds the current map y number
  118. Dim MapName As String   'holds the name of the map
  119. Dim screenX As Integer  'holds the current location of the screen on the map
  120. Dim screenY As Integer  'holds the current location of the screen on the map
  121. Dim charPosX As Integer 'holds the coords to center the character on the screen
  122. Dim charPosY As Integer 'holds the coords to center the character on the screen
  123. Dim sound As Boolean     'holds whether to play sounds or not
  124. 'symbolic constants
  125. 'directions
  126. Const dLEFT As Integer = 1    'left direction
  127. Const dUP As Integer = 2      'up direction
  128. Const dRIGHT As Integer = 3   'right direction
  129. Const dDOWN  As Integer = 4   'down direction
  130. 'animation frames
  131. Const aLEFT As Integer = 2    'left animation
  132. Const aUP As Integer = 104    'up animation
  133. Const aRIGHT As Integer = 206 'right animation
  134. Const aDOWN As Integer = 308  'down animation
  135. 'when the user presses a key
  136. Private Sub picBuf_KeyDown(KeyCode As Integer, Shift As Integer)
  137. Dim X As Integer 'counting variable
  138. 'if movement, turn the mouse cursor into the invisible icon.
  139. 'simply making a mouse cursor that was invisible is easier
  140. 'then using API calls.
  141. frmDisplay.MouseIcon = frmTextures.picInvisible.Picture
  142. 'copy the current location of the character into the lastx and lasty variables.
  143. lastX = screenX
  144. lastY = screenY
  145. 'determine how to act, based on which key the user presses.
  146. Select Case KeyCode
  147. Case Is = 37    'left arrow key
  148.     animX = aLEFT   'set the animation frame to the proper direction
  149.     direction = dLEFT 'set the direction
  150. Case Is = 38    'up arrow key
  151.     animX = aUP 'set the animation frame to the proper direction
  152.     direction = dUP
  153. Case Is = 39    'right arrow key
  154.     animX = aRIGHT
  155.     direction = dRIGHT
  156. Case Is = 40    'down arrow key
  157.     animX = aDOWN
  158.     direction = dDOWN
  159. Case Is = 27    'escape key
  160.     'ask if the user would like to exit
  161.     If MsgBox("Are you sure you would like to exit?", vbYesNo + vbDefaultButton2 + vbQuestion, "Exit?") = vbYes Then End
  162. Case Is = 109   'minus key - increases screen size
  163.     Speed = Speed - 2
  164.     If Speed < 5 Then Speed = 5
  165. Case Is = 107   'plus key - decreases screen size
  166.     Speed = Speed + 2
  167.     If Speed > 20 Then Speed = 20
  168. Case Is = 83    'the S key
  169.     'turn sound on or off
  170.     If sound = True Then
  171.         sound = False
  172.     Else
  173.         sound = True
  174.     End If
  175. End Select
  176. 'see if the movement timer should be enabled
  177. If KeyCode >= 37 And KeyCode <= 40 Then 'if a direction key's been pressed
  178.     tmrMove.Enabled = True
  179. End If
  180. End Sub
  181. Private Sub picBuf_KeyUp(KeyCode As Integer, Shift As Integer)
  182. 'disable the movement timer
  183. tmrMove.Enabled = False
  184. End Sub
  185. Private Sub Form_Load()
  186. 'initialize the variables
  187. animX = 2
  188. animY = 1
  189. screenX = 10
  190. screenY = 10
  191. charX = screenX + charPosX + 25
  192. charY = screenY + charPosY + 25
  193. sound = True
  194. BackBuilt = False
  195. 'maps are loaded in the following way:
  196. 'take the mapX, then add the letter 'a' then take the mapY, then add ".map"
  197. 'so, the first map is called 0a0.map, the map beside it is called
  198. '1a0.map, and the map above the first is called 0a1.map
  199. 'eventually the middle letter will stand for the area, eg a = lev 1, b = lev 2
  200. mapx = 0    'the current map
  201. mapy = 0
  202. Speed = 15  'set the initial walking speed
  203. 'set the size of the main picture box
  204. 'change the number to make the picture bigger or smaller, but the number can't be
  205. 'large then 1 or smaller then 0
  206. picBuf.Height = Int(Screen.Height * 0.8)
  207. picBuf.Wi